# -*- coding: utf-8 -*-
# @Time: 2022/4/29 13:46
# @Author: 发抖的小喵喵
# @Email: panyi_20210601@163.com
# @File: 同步退货订单信息.py
# @Project: haixin
# @Software: PyCharm

from random import randint
import time
import json

from test_case.haixin.Method.Post import post_method


def returnOrder():
    """
    客户退货的订单列表，同步到我们数据库
    :return:
    """
    url = "https://api-sit.shwoody.com/ma/reOrder/returnOrder"

    data = {
        "shopId": "2024",
        "cashNo": "0007",  # 收款机号
        "saleNo": "2024041017571937130",  # 销售流水号
        "userId": "1768177567753400323",
        "refundSn": time.strftime("%Y%m%d%H%M%S") + str(randint(10000, 99999)),  # 退款编号
        "refundSuccess": True,  # 是否成功退货  # True False
        "refundAmount": 0  # 现金支付的金额
    }
    print(json.dumps(data))
    print(f"退款单号{data.get('refundSn')}")

    response = post_method(data, url)
    print("接口响应数据：" + str(response))


if __name__ == "__main__":
    returnOrder()
